<?php 

if(empty($_FILES)){
	echo "上传失败";exit;
}

$upload = current($_FILES);

if($upload['error']>0){
	echo "上传失败,错误代码：".$upload['error'];
	exit;
}

$allowType = ['jpg','png','gif'];

$fileType = explode('.', $upload['name']);

$fileType = end($fileType);

if(!in_array($fileType , $allowType )){
	echo "上传失败,类型不允许";
	exit;
}

is_dir('./Upload') ||  mkdir('./Upload');

$name = uniqid();

if(move_uploaded_file($upload['tmp_name'],'./Upload/'.$name.'.'.$fileType)){
	echo "上传成功";
}else{
	echo "上传失败,新重新上传";
}

header("Location:./index.php");












 ?>